Is this the correct recursive way to write curry function